/**
 * Created with CLion.
 * Description: 
 * User: loong
 * Date: 2021-03-22
 * Time: 14:54
 */
#ifndef CODSEEGMENT_DIAGRAMVIEW_H
#define CODSEEGMENT_DIAGRAMVIEW_H

#include <QtWidgets>


class DiagramView
        : public QGraphicsView
{
    Q_OBJECT

public:

    enum ActionIndex
    {
        InsertRect = 0,
        InsertCircle,
        InsertDiamond,
        InsertStraightLine,
        InsertRightAngleLine,
        CutAction,
        CopyAction,
        PasteAction,
        RotateAction,
        RotateBackAction,
        FlipAction,
        SelectAllAction,
        DeleteAction,
        PropertiesAction,
        AutoAlign
    };

public:
    explicit DiagramView(QGraphicsScene *scene);

    ~DiagramView() override;

    void SetupMatrix();
private:
    void InitActions();
    void InitViewMenu();
    QAction * AddAction(const QString& text, QObject* slotObj, const char* slotFunction, const QString& shortcut = QString());

public slots:
    void Zoom(int i);
    /*[] 将下列槽改做信号 */
    void ItemCut();
    void ItemCopy();
    void ItemPaste();

    void ItemSelectAll();

    void RotateBackSelection();
    void FlipSelection();

    bool ItemProperties();
signals:
    void SignalItemAlgin();

    void SignalRectItem();

    void SignalCircleItem();

    void SignalDiamondItem();

    void SignalStraightLineItem();

    void SignalRightAngleItem();

    void SignalDeleteItem();

    void SignalRotateItem();
protected:
    void wheelEvent(QWheelEvent *event) override;
    void contextMenuEvent(QContextMenuEvent *event) override;
private:
    //ViewMode                    current_mode_;
    //QList<DiagramBaseItem*>     items_;
    //QList<DiagramBaseItem*>     selected_items_;
    //DiagramBaseItem*            new_item_;
    QPointF                     mouse_press_point_;
    QMenu                       diagram_context_menu_;
    QMenu                       item_context_menu_;

    int                         zoom_;
    int                         rotate_;

};


#endif //CODSEEGMENT_DIAGRAMVIEW_H
